package com.eva.androidlibrary.widget.mdprogressdialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.eva.androidlibrary.R;

/**
 * Material Design 风格的progressdialog
 */
public class MdProgressDialog extends Dialog {
    LoadingButton loadingButton;
    TextView textView;

    public MdProgressDialog(Context context) {
        super(context);
        init();
    }

    public MdProgressDialog(Context context, int theme) {
        super(context, theme);
        init();
    }

    protected MdProgressDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        init();
    }

    void init() {
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        this.setContentView(R.layout.lib_mdprogress);
        loadingButton = (LoadingButton) findViewById(R.id.lbtn_default);
//        textView = (TextView) findViewById(R.id.loading_text);
//        textView.setVisibility(View.VISIBLE);
        loadingButton.setTargetProgress(180);
        loadingButton.setCallback(new LoadingButton.Callback() {
            @Override
            public void complete() {
                dismiss();
            }
        });
    }

    public void loadingSuccess() {
//        textView.setVisibility(View.INVISIBLE);
        loadingButton.startDrawable();
    }


}